<template>
  <view class="search-page" >
    <view class="custom-header" :style="{ paddingTop: statusBarHeight + 'px' }">
      <view class="header-content">
        <view class="header-left" @click="handleCancel">
          <image
            class="search-icon"
            src="https://jyoungy.oss-cn-beijing.aliyuncs.com/jyy-mini-sale/icons/back.png"
            mode="aspectFit"
          ></image>
        </view>
        <view class="header-center">
          <image
            class="logo"
            src="https://jyoungy.oss-cn-beijing.aliyuncs.com/jyy-mini-sale/logo.png"
            mode="heightFix"
          ></image>
        </view>
        <view class="header-right">
          <!-- 右侧预留空间，保持对称 -->
        </view>
      </view>
    </view>
    <view class="search-header">
      <view class="search-input-wrap">
        <image class="search-icon" src="https://jyoungy.oss-cn-beijing.aliyuncs.com/jyy-mini-sale/icons/search.png" mode="aspectFit"></image>
        <input 
          class="search-input" 
          type="text" 
          v-model="searchText"
          placeholder="请输入搜索关键词"
          confirm-type="search"
          @confirm="handleSearch"
        />
      </view>
      <text class="cancel-btn" @click="handleCancel">取消</text>
    </view>
  </view>
</template>

<script>
export default {
  data() {
    return {
      statusBarHeight: 0,
      searchText: ''
    }
  },
  mounted() {
    this.statusBarHeight = uni.getSystemInfoSync().statusBarHeight;
  },
  methods: {
    handleSearch() {
      // 实现搜索逻辑
      console.log('搜索关键词：', this.searchText)
    },
    handleCancel() {
      uni.navigateBack()
    }
  }
}
</script>

<style lang="scss" scoped>
.search-page {
  min-height: 100vh;
  background-color: #ffffff;
}
.custom-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  background-color: #fff;
  z-index: 999;

  .header-content {
    height: 88rpx;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: 0 2rpx 10rpx rgba(0, 0, 0, 0.05);
    padding: 0 30rpx;
  }

  .header-left {
    width: 60rpx;
    height: 60rpx;
    display: flex;
    align-items: center;
    justify-content: center;

    .search-icon {
      width: 40rpx;
      height: 40rpx;
    }
  }

  .header-center {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;

    .logo {
      height: 50rpx;
    }
  }

  .header-right {
    width: 60rpx;
  }
}

.search-header {
  padding: 20rpx 30rpx;
  display: flex;
  align-items: center;
  background-color: #ffffff;
  
  .search-input-wrap {
    flex: 1;
    height: 72rpx;
    background-color: #F5F5F5;
    border-radius: 36rpx;
    display: flex;
    align-items: center;
    padding: 0 30rpx;
    margin-right: 20rpx;
    
    .search-icon {
      width: 32rpx;
      height: 32rpx;
      margin-right: 20rpx;
    }
    
    .search-input {
      flex: 1;
      height: 100%;
      font-size: 28rpx;
    }
  }
  
  .cancel-btn {
    font-size: 28rpx;
    color: #333333;
  }
}
</style> 